package com.jin.repository;

import com.jin.model.Spu;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;


//后面的两个参数是返回实体的类型，还有实体的主键
public interface SpuRepository extends JpaRepository<Spu,Long> {
    Spu findOneById(Long id);
    //自定义接口方法（复杂sql）下面是根据二级分类查询
    Page<Spu> findByCategoryIdOrderByCreateTimeDesc(Long cid, Pageable pageable);
    //根据一级分类查询
    Page<Spu> findByRootCategoryIdOrderByCreateTimeDesc(Long cid, Pageable pageable);

    List<Spu> findByIdIn(List<Long> ids);

    Page<Spu> findByTitleLikeOrSubtitleLike(String keyword, String keyword1, Pageable pageable);

}
